package persistencia;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import negocio.Factura;


public class AdPerFactura {
	private static AdPerFactura pool;
	
	private AdPerFactura(){
		
	};
	
	public static AdPerFactura getInstancia(){
		if (pool==null) {
			pool = new AdPerFactura();
		}
		return pool;
	}
	
	
	public Vector<Factura> getAll(){
		Vector<Factura> auxFacturas = new Vector<Factura>();
		Conn c1 = new Conn();
		Connection con = c1.getConnection();
		
		try
		{
			String senten = "SELECT mes, anio, facturaid from facturas" ;
			PreparedStatement ps = null;
			ps = con.prepareStatement(senten);
			ResultSet result = ps.executeQuery();
			while (result.next())
			{
				Factura f = new Factura(Integer.parseInt(result.getString("mes")), Integer.parseInt( result.getString("anio")), Integer.parseInt(result.getString("facturaid")));
			
				Conn c2 = new Conn();
				Connection con2 = c2.getConnection();
				PreparedStatement ps2 = null;
				ps = con2.prepareStatement("SELECT ")
				
				auxFacturas.add(f);
			}
			
			return auxFacturas;
		}
	      catch( SQLException e ) 
	      {
				System.out.println("Mensaje Error al Borrar Cliente: " + e.getMessage());
				System.out.println("Stack Trace al Borrar Cliente: " + e.getStackTrace());
			}
	      return null;
	}

}
	
